#ifndef VNCSERVER_H__
#define VNCSERVER_H__

#include "vncClient.h"

// Includes
#include "stdhdrs.h"
#include <omnithread.h>
#include <list>

// Define a datatype to handle lists of windows we wish to notify
typedef std::list<HWND> vncNotifyList;

// Some important constants;
const int MAX_CLIENTS = 1024;

class vncSockConnect;
class vncCorbaConnect;

class vncServer
{
public:
	enum AcceptQueryReject {aqrAccept, aqrQuery, aqrReject};

   vncServer();
   ~vncServer();
   BOOL SockConnect(BOOL On);
   BOOL SockConnected();
   UINT GetPort() { return m_port; };
   virtual BOOL LoopbackOk() {return m_loopback_allowed;};
   BOOL LoopbackOnly();
   void SetName(const char * name);

   virtual void SetQueryAccept(const BOOL setting) {m_queryaccept = setting;};
   virtual BOOL QueryAccept() {return m_queryaccept;};
//--   BOOL Authenticated(vncClientId clientid);
   BOOL GetBeepConnect() {return m_beepConnect;};
   virtual BOOL GetBeepDisconnect() {return m_beepDisconnect;};
   virtual BOOL FileTransfersEnabled() {return m_enable_file_transfers;}
   // Timeout for automatic disconnection of idle connections
   virtual void SetAutoIdleDisconnectTimeout(const UINT timeout) {m_idle_timeout = timeout;};
   virtual UINT AutoIdleDisconnectTimeout() {return m_idle_timeout;};
   // Client info retrieval/setup
   vncClient* GetClient(vncClientId clientid);
   vncClientList ClientList();

   void RemoveClient(vncClientId clientid);
   void AddAuthHostsBlacklist(const char *machine);
   void RemAuthHostsBlacklist(const char *machine);
   vncClientId AddClient(VSocket *socket, BOOL reverse, BOOL shared);
   vncClientId AddClient(VSocket *socket, BOOL reverse, BOOL shared, BOOL keysenabled, BOOL ptrenabled);
protected:
	// Blacklist structures
	struct BlacklistEntry {
		BlacklistEntry *_next;
		char *_machineName;
		LARGE_INTEGER _lastRefTime;
		UINT _failureCount;
		BOOL _blocked;
	};
	BlacklistEntry		*m_blacklist;

   // Connection servers
   vncSockConnect		*m_socketConn;
   vncCorbaConnect		*m_corbaConn;

   // Name of this desktop
   char				*m_name;

   BOOL				m_autoportselect;
   BOOL				m_loopbackOnly;
   BOOL				m_loopback_allowed;
   BOOL				m_queryaccept;
   BOOL				m_beepConnect;
   BOOL				m_beepDisconnect;
   BOOL				m_enable_file_transfers;
   BOOL				m_enable_remote_inputs;
   UINT				m_port;
   UINT				m_port_http;
   UINT				m_idle_timeout;
   vncClientId			m_nextid;
   vncClientList		m_unauthClients;
   vncClientList		m_authClients;
   vncClient			*m_clientmap[MAX_CLIENTS];
   omni_mutex			m_desktopLock;
   omni_mutex			m_clientsLock;
   omni_condition		*m_clientquitsig;
private:

   
};

#endif // VNCSERVER_H__